<?php
if(!defined('IN_IBEIKE')) {
	exit('Access Denied');
}

class table_common_attachment extends common_table
{
	public function __construct() {

		$this->_table = 'common_attachment';
		$this->_pk    = 'aid';

		parent::__construct();
	}
	public function fetch_all_by_aid($aid){
		if(!empty($aid)&&$aid){
			return DB::fetch_all('SELECT * FROM %t WHERE aid=%s',array($this->_table,$aid));//返回数组包含各个字段的值
		}
		return false;
	}
	public function insert($data, $return_insert_id = false, $replace = false, $silent = false){
		if(!empty($data)){
			return DB::insert($this->_table,$data, $return_insert_id,$replace,$silent);//返回上一步 INSERT 操作产生的 ID
		}
		return false;
	
	}
	public function fetch_all_by_field($data){//这里写一个公共的方法,$data为字段=>值,用来查询符合这些字段和值的数据
		if(!empty($data) && is_array($data)){
                    $sign="";
                    foreach ($data as $k => $v){
                        $condition=$sign." ".$k."=".$v." ";
                        $sign="AND";
                    } 
			return DB::fetch_all("SELECT * FROM %t WHERE %s",array($this->_table,$condition));
		}else{
			return false;
		}
	}
}